<template>
  <div>
    <el-form :inline="true" class="demo-form-inline">
      <el-form-item  label="" style="margin-left: 15px;top:-5px;position: relative;">
        <el-select v-model="selectData" placeholder="请选择">
          <el-option label="全部城市" :value="''"></el-option>
          <el-option label="苏州" value="苏州"></el-option>
          <el-option label="郑州" value="郑州"></el-option>
		  <el-option label="成都" value="成都"></el-option>
		  <el-option label="西安" value="西安"></el-option>
		  <el-option label="洛阳" value="洛阳"></el-option>
		  <el-option label="合肥" value="合肥"></el-option>
		  <el-option label="柳州" value="柳州"></el-option>
		  <el-option label="济南" value="济南"></el-option>
        </el-select>
      </el-form-item>
      <!-- <el-form-item label="" style="margin-left: 15px">
        <el-input v-model="keywords" placeholder="请输入搜索关键词"></el-input>
      </el-form-item>
      <el-form-item>
        <el-button style="top:-5px;position: relative;" @click="getDatas" type="primary">搜索</el-button>
      </el-form-item> -->
    </el-form>
    <el-table class="mb20" :data="tableData" border style="width: 100%">
      <el-table-column prop="numbers" label="试驾人手机号码" />
      <el-table-column prop="name" label="试驾人姓名" />
     <el-table-column prop="type" label="试驾车型" />
      <el-table-column prop="city" label="城市" />
      <el-table-column prop="jifen" label="积分" />
      <el-table-column prop="status" label="试驾反馈">
        <template #default="scope">
          {{ scope.row.cpsseven ? scope.row.cpsseven : scope.row.cpilike }}
        </template>
      </el-table-column>
      <el-table-column prop="status" label="签到状态">
        <template #default="scope">
			
			<el-tag
			    :type="scope.row.wdhx==1?'success':''"
			    effect="dark">
			   {{ scope.row.wdhx==1 ? "已签到核销" : "未签到核销" }}
			  </el-tag>
          
        </template>
      </el-table-column>
      
    </el-table>
    <el-pagination
      class="mt20"
      v-model:currentPage="page"
      @current-change="getData"
      :page-size="10"
      background
      layout="prev, pager, next"
      :total="total"
    >
    </el-pagination>
  </div>
</template>

<script>
import { ElMessageBox, ElMessage } from "element-plus";
export default {
  components: {},
  watch: {
    times() {
      this.form.starttime = this.times[0];
      this.form.endtime = this.times[1];
    },
  },
  data() {
    return {
      status: {
        0: "审核中",
        1: "正常",
        2: "隐藏",
        3: "不通过",
      },
      viewarr: [],
      modalStatewins: false,
      hdqtxmname: "", //     名称
      hdjifen: "", //   加积分
      numbers: "", //  手机
      modalStatewin: false,
      qrcode: null,
      modalStatecode: false,
      vtimes: ["", ""],
      formLabelWidth: "120px",
      times: "",
      form: {
        is_show: "1",
        images: "",
        content: "",
        jifen: "",
        starttime: "",
        endtime: "",
        title: "",
        is_hot: "0",
        author: "0",
      },
      tableData: [],
      rules: {
        title: [
          {
            required: true,
            message: "请填写标题",
            trigger: "blur",
          },
        ],
        jifen: [
          {
            required: true,
            message: "请填写积分",
            trigger: "blur",
          },
        ],
        content: [
          {
            required: true,
            message: "请填写内容",
            trigger: "blur",
          },
        ],
        starttime: [
          {
            required: true,
            message: "请选择时间",
            trigger: "change",
          },
        ],
      },
      pid: [],
      bqlist: [],
    };
  },
  async mounted() {
    // await this.$http.post("index.php/index/Admins/bqlist").then((data) => {
    //   this.bqlist = data;
    // });
    await this.getData();
  },
  methods: {
    getDatas(){
      this.page=1;
      this.getData()
    },
    getData() {
      this.$http
        .post("/index.php/index/goodses/sjxcxlist", {
          page: this.page,
          pagesize: 10,
          city: this.selectData,
          names:this.keywords
        })
        .then((datas) => {
			
          if(datas.length>0){
          var data = datas[0];
          this.tableData = data;
          this.total = datas[1];
          }else{
            this.tableData = [];
             this.total = 0;
          }
         
        });
    },
    submit(ref) {
      console.log(this.$refs);
      this.doRules(this.$refs[ref]).then(() => {
        if (this.id) this.form.id = this.id;

        this.$http
          .post(
            this.id
              ? "/index.php/index/Userinfo/hdedittj"
              : "/index.php/index/Userinfo/hdadd",
            this.form
          )
          .then((data) => {
            console.log(data);
            this.modalState = false;
            ElMessage({
              message: this.id ? "编辑成功" : "新增成功",
              type: "success",
            });
            this.getData();
          });
      });
    },
    remove(data) {
      this.$http
        .post("/index.php/index/Userinfo/hddel", { id: data.row.id })
        .then((data) => {
          ElMessage({
            message: "删除成功",
            type: "success",
          });
          this.getData();
        });
    },
    handleAvatarSuccess(file) {
      this.form.image = file.data;
    },
  },
};
</script>
